#include "RenderToVertexBuffer.h"
#include "MaterialManager.h"

namespace PVM
{
	RenderToVertexBuffer::RenderToVertexBuffer() :
	mOperationType(RenderOperation::OT_TRIANGLE_LIST),
	mResetsEveryUpdate(false),
	mResetRequested(true),
	mMaxVertexCount(1000)
	{
		mVertexData = new VertexData;
	}
	
	RenderToVertexBuffer::~RenderToVertexBuffer()
	{
		delete mVertexData;
	}
	
	VertexDeclaration* RenderToVertexBuffer::getVertexDeclaration()
	{
		return mVertexData->vertexDeclaration;
	}
	
	void RenderToVertexBuffer::setRenderToBufferMaterialName(const std::string& materialName)
	{
		mMaterial = MaterialManager::getSingleton().getByName(materialName);
		
		if (mMaterial.isNull())
			PVM_EXCEPT("Could not find material " + materialName,
					   "RenderToVertexBuffer::setRenderToBufferMaterialName");
		
		mMaterial->load();
	}
}
